Conditions | 1 |
Paths | 1 |
Total Lines | 160 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | /* jshint -W101, -W098 */ |
||
38 | describe('data api', function() { |
||
39 | it('test address', function(cb) { |
||
40 | client.address("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp", function(err, address) { |
||
41 | assert.ifError(err); |
||
42 | assert.ok(address['address']); |
||
43 | assert.equal(address['address'], '1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp'); |
||
44 | |||
45 | cb(); |
||
46 | }); |
||
47 | }); |
||
48 | it('test addressTransactions', function(cb) { |
||
49 | client.addressTransactions("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp", {limit: 23}, function(err, address_txs) { |
||
50 | assert.ifError(err); |
||
51 | assert.ok(address_txs['data']); |
||
52 | assert.ok(address_txs['total']); |
||
53 | assert.ok(address_txs['data'].length === 23); |
||
54 | |||
55 | cb(); |
||
56 | }); |
||
57 | }); |
||
58 | it('test addressUnconfirmedTransactions', function(cb) { |
||
59 | client.addressUnconfirmedTransactions("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp", {limit: 23}, function(err, address_txs) { |
||
60 | assert.ifError(err); |
||
61 | assert.ok('data' in address_txs); |
||
62 | assert.ok('total' in address_txs); |
||
63 | // assert.ok(address_txs['total'] >= address_txs['data'].length); |
||
64 | |||
65 | cb(); |
||
66 | }); |
||
67 | }); |
||
68 | it('test addressUnspentOutputs', function(cb) { |
||
69 | client.addressUnspentOutputs("16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", {limit: 23}, function(err, address_utxo) { |
||
70 | assert.ifError(err); |
||
71 | assert.ok('data' in address_utxo); |
||
72 | assert.ok('total' in address_utxo); |
||
73 | assert.ok(address_utxo['total'] >= address_utxo['data'].length); |
||
74 | |||
75 | cb(); |
||
76 | }); |
||
77 | }); |
||
78 | it('test batchAddressUnspentOutputs', function(cb) { |
||
79 | client.batchAddressUnspentOutputs(["16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", "16fVUD4yCuabS153FJGtmLL8tgydsrf6vu"], {limit: 23}, function(err, address_utxo) { |
||
80 | assert.ifError(err); |
||
81 | assert.ok('data' in address_utxo); |
||
82 | assert.ok('total' in address_utxo); |
||
83 | assert.ok(address_utxo['total'] >= address_utxo['data'].length); |
||
84 | cb(); |
||
85 | }); |
||
86 | }); |
||
87 | it('test verifyAddress', function(cb) { |
||
88 | client.verifyAddress("16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", "HPMOHRgPSMKdXrU6AqQs/i9S7alOakkHsJiqLGmInt05Cxj6b/WhS7kJxbIQxKmDW08YKzoFnbVZIoTI2qofEzk=", function(err, result) { |
||
89 | assert.ifError(err); |
||
90 | assert.ok(result); |
||
91 | |||
92 | cb(); |
||
93 | }); |
||
94 | }); |
||
95 | it('test block by hash', function(cb) { |
||
96 | client.block("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf", function(err, block) { |
||
97 | assert.ifError(err); |
||
98 | assert.ok(block['hash']); |
||
99 | assert.equal(block['hash'], '000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf'); |
||
100 | |||
101 | cb(); |
||
102 | }); |
||
103 | }); |
||
104 | it('test block by height', function(cb) { |
||
105 | client.block(200000, function(err, block) { |
||
106 | assert.ifError(err); |
||
107 | assert.ok(block['hash']); |
||
108 | assert.equal(block['hash'], '000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf'); |
||
109 | |||
110 | cb(); |
||
111 | }); |
||
112 | }); |
||
113 | it('test blockTransactions', function(cb) { |
||
114 | client.blockTransactions("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf", {limit: 23}, function(err, block_txs) { |
||
115 | assert.ifError(err); |
||
116 | assert.ok(block_txs['data']); |
||
117 | assert.ok(block_txs['total']); |
||
118 | assert.ok(block_txs['data'].length === 23); |
||
119 | |||
120 | cb(); |
||
121 | }); |
||
122 | }); |
||
123 | it('test allBlocks', function(cb) { |
||
124 | client.allBlocks({page:2, limit: 23, sort_dir: 'asc'}, function(err, blocks) { |
||
125 | assert.ifError(err); |
||
126 | assert.ok(blocks['data']); |
||
127 | assert.ok(blocks['total']); |
||
128 | assert.ok(blocks['data'].length === 23); |
||
129 | assert.equal(blocks['data'][0]['hash'], '000000000cd339982e556dfffa9de94744a4135c53eeef15b7bcc9bdeb9c2182'); |
||
130 | assert.equal(blocks['data'][1]['hash'], '00000000fc051fbbce89a487e811a5d4319d209785ea4f4b27fc83770d1e415f'); |
||
131 | |||
132 | cb(); |
||
133 | }); |
||
134 | }); |
||
135 | it('test blockLatest', function(cb) { |
||
136 | client.blockLatest(function(err, block) { |
||
137 | assert.ifError(err); |
||
138 | assert.ok(block['hash']); |
||
139 | |||
140 | cb(); |
||
141 | }); |
||
142 | }); |
||
143 | it('test coinbase transaction', function(cb) { |
||
144 | client.transaction("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", function(err, tx) { |
||
145 | assert.ifError(err); |
||
146 | assert.equal(tx['hash'], "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); |
||
147 | assert.equal(tx['enough_fee'], null); |
||
148 | |||
149 | cb(); |
||
150 | }); |
||
151 | }); |
||
152 | it('test random transaction #1', function(cb) { |
||
153 | client.transaction("c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1", function(err, tx) { |
||
154 | assert.ifError(err); |
||
155 | assert.equal(tx['hash'], "c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1"); |
||
156 | assert.ok(tx['confirmations']); |
||
157 | assert.equal(tx['enough_fee'], true); |
||
158 | assert.equal(tx['high_priority'], false); |
||
159 | |||
160 | cb(); |
||
161 | }); |
||
162 | }); |
||
163 | it('test batch transactions', function(cb) { |
||
164 | client.transactions([ |
||
165 | "c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1", |
||
166 | "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", |
||
167 | "4bbe6feeb50e47e2de5ef6a9d7378363823611dd07d4a5ea1799da9ae6a21665", |
||
168 | "6c0d3156621051a86b8af3f23dfe211e8a17a01bffe3c2b24cbee65139873c6a", |
||
169 | "356210d6b8143e23d0cf4d0dae0ac686015a13fe3b2b46b1cc43a71a36c73355", |
||
170 | "a40d1eee0cec3d963d8df2870bd642bd3fd07163e864aeb90fa5efe9ea91c998", |
||
171 | "1c7e3c9823baa9bb70b09ed666e8a6b3120b07f84429ed41f05d5504bd58f188", |
||
172 | "1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80", |
||
173 | "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" // not found |
||
174 | ], function(err, txs) { |
||
175 | assert.ifError(err); |
||
176 | |||
177 | assert.equal(Object.keys(txs['data']).length, 8); |
||
178 | |||
179 | var tx1 = txs['data']["c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1"]; |
||
180 | assert.equal(tx1['hash'], "c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1"); |
||
181 | assert.ok(tx1['confirmations']); |
||
182 | assert.equal(tx1['enough_fee'], true); |
||
183 | assert.equal(tx1['high_priority'], false); |
||
184 | |||
185 | var tx2 = txs['data']["0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"]; |
||
186 | assert.equal(tx2['hash'], "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); |
||
187 | assert.equal(tx2['enough_fee'], null); |
||
188 | |||
189 | var tx8 = txs['data']["1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80"]; |
||
190 | assert.equal(tx8['hash'], "1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80"); |
||
191 | |||
192 | assert.ok(!txs['data']['ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff']); |
||
193 | |||
194 | cb(); |
||
195 | }); |
||
196 | }); |
||
197 | }); |
||
198 | |||
475 |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.